//
//  BannerViewController.m
//  MoXiProject
//
//  Created by 沈晨宇 on 2017/6/29.
//  Copyright © 2017年 周筱雯. All rights reserved.
//

#import "BannerViewController.h"

@interface BannerViewController ()<UIScrollViewDelegate>
{
    UILabel* titleLable;
    UIImageView* iconImage;
    UILabel* timeLable;
    UILabel* contentLable;
    
}
@property(nonatomic,strong)UIScrollView* dataScroll;
@end

@implementation BannerViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initNav];
    [self initUI];
    NSLog(@"%@",self.createTime);
    
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)initNav{
    
    [self.navigationItem setTitle:@"推广"];
    [self.view setBackgroundColor:[UIColor whiteColor]];
    
}

-(void)initUI{
    self.dataScroll=[UIScrollView new];
    self.dataScroll.delegate=self;
    //    self.dataScroll.backgroundColor=[UIColor lightGrayColor];
    self.dataScroll.showsVerticalScrollIndicator=NO;
    [self.view addSubview:self.dataScroll];
    
    if(iPhoneX){
        
        [self.dataScroll mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.mas_equalTo(DEF_DEVICE_WIDTH);
            make.height.mas_equalTo(DEF_DEVICE_HEIGHT-88-34);
            make.top.equalTo(self.view).with.offset(0);
            make.leading.equalTo(self.view).with.offset(0);
        }];
        
    }else{
        
        [self.dataScroll mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.mas_equalTo(DEF_DEVICE_WIDTH);
            make.height.mas_equalTo(DEF_DEVICE_HEIGHT-64);
            make.top.equalTo(self.view).with.offset(0);
            make.leading.equalTo(self.view).with.offset(0);
        }];
        
    }
    
    
    
    titleLable=[UILabel new];
    titleLable.text=self.imgTitle;
    titleLable.font=DEF_MyFont(18);
    titleLable.textAlignment=NSTextAlignmentCenter;
    titleLable.textColor=baseBlackColor;
    [self.dataScroll addSubview:titleLable];
    [titleLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(DEF_DEVICE_WIDTH-30);
        make.height.mas_equalTo(18);
        make.top.equalTo(self.dataScroll).with.offset(20);
        make.leading.equalTo(self.dataScroll).with.offset(15);
    }];
    
    timeLable=[UILabel new];
    timeLable.text=self.createTime;
    timeLable.font=DEF_MyFont(14);
    timeLable.textAlignment=NSTextAlignmentCenter;
    timeLable.textColor=baseLightBlackColor;
    [self.dataScroll addSubview:timeLable];
    [timeLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(DEF_DEVICE_WIDTH-30);
        make.height.mas_equalTo(14);
        make.top.equalTo(titleLable.mas_bottom).with.offset(15);
        make.leading.equalTo(self.dataScroll).with.offset(15);
    }];
    
    iconImage=[UIImageView new];
    [iconImage sd_setImageWithURL:[NSURL URLWithString:self.imgUrl]];
    [self.dataScroll addSubview:iconImage];
    [iconImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(DEF_DEVICE_WIDTH-30);
        make.height.mas_equalTo(180);
        make.top.equalTo(timeLable.mas_bottom).with.offset(20);
        make.leading.equalTo(self.dataScroll).with.offset(15);
    }];
    
    CGSize contentLableSize=[self.Description boundingRectWithSize:CGSizeMake(DEF_DEVICE_WIDTH-30, MAXFLOAT) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:@{NSFontAttributeName : DEF_MyFont(14)} context:nil].size;
    
    contentLable=[UILabel new];
    contentLable.text=self.Description;
    contentLable.numberOfLines=0;
    contentLable.font=DEF_MyFont(14);
    contentLable.textAlignment=NSTextAlignmentLeft;
    contentLable.textColor=baseLightBlackColor;
    [self.dataScroll addSubview:contentLable];
    [contentLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(DEF_DEVICE_WIDTH-30);
        make.height.mas_equalTo(contentLableSize.height+1);
        make.top.equalTo(iconImage.mas_bottom).with.offset(20);
        make.leading.equalTo(self.dataScroll).with.offset(15);
    }];
    
 
    
    [self.dataScroll setContentSize:CGSizeMake(DEF_DEVICE_WIDTH, 20+16+15+16+20+180+20+contentLableSize.height+1+15)];
    
}

@end
